version: '3.7'
services:
  keycloak:
    image: quay.io/keycloak/keycloak:24.0.2
    command: start-dev
    environment:
      KC_DB: postgres
      KC_DB_URL_HOST: db_postgres
      KC_DB_URL_DATABASE: els_keycloak
      KC_DB_USERNAME: keycloak
      KC_DB_PASSWORD: password
      KC_DB_SCHEMA: public
      KEYCLOAK_ADMIN: admin
      KEYCLOAK_ADMIN_PASSWORD: admin
    ports:
      - "8890:8080"
    depends_on:
      db_postgres:
        condition: service_healthy
    networks:
      - keycloak-dev-network
  db_postgres:
    image: postgres
    command: postgres -c 'max_connections=200'
    volumes:
      - ./postgres-data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: els_keycloak
      POSTGRES_USER: keycloak
      POSTGRES_PASSWORD: password
    healthcheck:
      test: "exit 0"
    ports:
      - "5432:5432"
    networks:
      - keycloak-dev-network
  db_postgres_global:
    image: postgres:16.2-alpine
    command: postgres -c 'max_connections=200'
    volumes:
      - ./postgres_global_data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: els_global
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: admin
    ports:
      - "5435:5432"
    networks:
      - keycloak-dev-network
  pgadmin:
    container_name: pgadmin4_container
    image: dpage/pgadmin4:7
    restart: always
    environment:
      PGADMIN_DEFAULT_EMAIL: admin@admin.com
      PGADMIN_DEFAULT_PASSWORD: admin
    ports:
      - "5050:80"
    networks:
      - keycloak-dev-network
    volumes:
      - ./pgadmin_data:/var/lib/pgadmin
volumes:
  postgres_data:
  postgres_global_data:
  pgadmin_data:

networks:
  keycloak-dev-network:
    driver: bridge
